package com.twu.biblioteca;

public class User {

    String libraryNumber;
    String password;
    String username;
    String emailAddress;
    String phoneNumber;

    User(String libraryNumber, String password, String username, String emailAddress, String phoneNumber) {
        this.libraryNumber = libraryNumber;
        this.password = password;
        this.username = username;
        this.emailAddress = emailAddress;
        this.phoneNumber = phoneNumber;
    }

    public boolean matches(String libraryNumber, String password) {
        return this.libraryNumber.equals(libraryNumber) && this.password.equals(password);
    }

    public String toString() {
        return username + " " + emailAddress + " " + phoneNumber;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        User user = (User) o;

        return libraryNumber.equals(user.libraryNumber) && password.equals(user.password);
    }

    @Override
    public int hashCode() {
        int result = libraryNumber.hashCode();
        result = 31 * result + password.hashCode();
        return result;
    }
}
